// main.cpp
// Created by fyniny on 12/23/18.
//
#include "dispatchprocess.h"
#include "process.h"
#include "spooling.h"
int main(int argc, char* argv[]) {
    DispathProcess dis;
    // 输出进程
    Base* p1 = new process(MAX_OUTPUT_CONTAINER, PCB (process_id::process1, PROCESS_EXECUTABLE));
    Base* p2 = new process(MAX_OUTPUT_CONTAINER, PCB (process_id::process2, PROCESS_EXECUTABLE));
    // 一开始输出序列为空，spooling默认状态为阻塞
    Base* sp = new spooling(2 * MAX_OUTPUT_CONTAINER, PCB(process_id::spooling, PROCESS_WAIT_EMPTY_OUTPUT_BLOCK));

    // 把进程添加至调度进程
    dis.addProcess(process_id::process1, p1);
    dis.addProcess(process_id::process2, p2);
    dis.addProcess(process_id::spooling, sp);
    // 启动调度进程
    dis.run();
    // 程序结束
    delete p1;
    delete p2;
    delete sp;
}
